<template>
  <div style="height:100%;width:100%;position:relative;">
      <div class="pagetop">
          <div style="width:100%;float:left">
              <table style="width:100%;font-size:12px" border="0" class="table1style">
                  <col style="width:5%;" />
                  <col style="width:22%" />
                  <col style="width:4%" />
                  <col style="width:10%" />
                  <col style="width:5%" />
                  <col style="width:9%" />
                  <col style="width:3%" />
                  <col style="width:8%" />
                  <col style="width:4%" />
                  <col style="width:8%" />
                  <col style="width:4%" />
                  <col style="width:7%" />
                  <col style="width:5%" />
                  <col style="width:6%" />
                  <tr>
                      <td align="right">报告单元</td>
                      <td>
                          <el-select v-model="txtrptunit" @dblclick.native="popMultipleChk(txtrptunit, 'txtrptunit', rptunitOption, '请选择报告单元')" filterable clearable style="width:100%">
                              <el-option v-for="(item, index) in rptunitOption" :key="index" :value="item.data" :label="item.display"></el-option>
                          </el-select>
                      </td>
                      <td align="right">标本号</td>
                      <td>
                          <el-input v-model="txtsampleno" placeholder="" clearable></el-input>
                      </td>
                      <td align="right">送检医院</td>
                      <td>
                          <rm-ddl-common @change="hospitalchange" datatype="hospital" dataname="医院" v-model="txthospcode" width="100%"></rm-ddl-common>
                      </td>
                      <td align="right">科室</td>
                      <td>
                          <el-select v-model="txtdeptno" @dblclick.native="popMultipleChk(txtdeptno,'txtdeptno',deptOption,'申请科室选择')" filterable clearable>
                              <el-option v-for="(item,index) in deptOption" :key="index" :value="item.data" :label="item.display">
                              </el-option>
                          </el-select>
                      </td>
                      <td align="right">病&nbsp;&nbsp;&nbsp;&nbsp;区</td>
                      <td>
                          <rm-ddl-common :appendtobody="true" datatype="ward" dataname="病区" v-model="txtwardno" width="100%"></rm-ddl-common>
                      </td>
                      <td align="right">床&nbsp;&nbsp;&nbsp;&nbsp;号</td>
                      <td>
                          <el-input v-model="txtbedno" placeholder="" clearable></el-input>
                      </td>
                      <td align="right">急诊标志</td>
                      <el-select v-model="txtemer" placeholder="">
                          <el-option v-for="(item,index) in emerOptions" :key="index" :value="item.value" :label="item.label"></el-option>
                      </el-select>
                  </tr>
                  <tr>
                      <td align="right">报告日期</td>
                      <td>
                          <table>
                              <tr>
                                  <td>
                                      <el-date-picker v-model="rpt_startdt" :clearable="false" type="date" placeholder="选择日期" value-format="yyyy-MM-dd" style="width:100%;">
                                      </el-date-picker>
                                  </td>
                                  <td>至</td>
                                  <td>
                                      <el-date-picker v-model="rpt_enddt" type="date" :clearable="false" placeholder="选择日期" value-format="yyyy-MM-dd" style="width:100%;"> </el-date-picker>
                                  </td>
                              </tr>
                          </table>
                      </td>
                      <td align="right">条码号</td>
                      <td>
                          <el-input v-model="txtbarcode" placeholder="" clearable></el-input>
                      </td>
                      <td align="right">病人来源</td>
                      <td>
                          <rm-ddl-common datatype="seccode" kindno="PT" dataname="病人来源" v-model="txtpattypecode" width="100%"></rm-ddl-common>
                      </td>
                      <td align="right">姓名</td>
                      <td>
                          <el-input v-model="txtpatname" placeholder="" clearable></el-input>
                      </td>

                      <td align="right">病历号</td>
                      <td>
                          <el-input v-model="txtpatno" placeholder="" clearable></el-input>
                      </td>
                      <td align="right">审核者</td>
                      <td>
                          <rm-ddl-common @change="userinfochange" datatype="userinfo" dataname="用户" v-model="txtchkuserno" width="100%"></rm-ddl-common>
                      </td>
                      <td align="right">发布状态</td>
                      <td>
                          <el-select v-model="txtchkstate" placeholder="" style="width:100%">
                              <el-option v-for="(item,index) in chkOptions" :key="index" :value="item.value" :label="item.label"></el-option>
                          </el-select>
                      </td>
                  </tr>
                  <tr>
                      <td align="right">检验者</td>
                      <td>
                          <rm-ddl-common @change="rptuserinfochange" datatype="userinfo" dataname="用户" v-model="txtrptuserno" width="100%"></rm-ddl-common>
                      </td>
                      <td align="right">混样报告</td>
                      <td>
                          <el-select v-model="txtmixrpt" placeholder="请选择" style="width:100%">
                              <el-option key="0" label="全部报告" value="0"></el-option>
                              <el-option key="1" label="混样主报告" value="1"></el-option>
                              <el-option key="2" label="混样明细报告" value="2"></el-option>
                          </el-select>
                      </td>
                  </tr>
                  <tr>
                      <td colspan="14">
                          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                          <el-checkbox true-label="1" false-label="0" v-model="chkpositiveRpt">
                              仅阳性报告</el-checkbox>

                          <el-checkbox true-label="1" false-label="0" v-model="chkNoSignRpt">
                              仅未签名的报告</el-checkbox>

                          <el-checkbox true-label="1" false-label="0" v-model="chkForceSendOrBack">
                              强行发布/召回</el-checkbox>

                          <el-checkbox true-label="1" false-label="0" v-model="chkSendOutHosp">
                              仅发布外院</el-checkbox>
                      </td>
                  </tr>
              </table>
          </div>
          <div style="width:100%;float:left">
              <table style="float:right">
                  <tr>
                      <td>
                          <el-button type="primary" @click="btnQuery">查询</el-button>
                      </td>
                      <td>
                          <el-button @click="btnSort">排序</el-button>
                      </td>
                      <td>
                          <el-button @click="btnClear">清除</el-button>
                      </td>
                      <td>
                          <el-button @click="btnPrint">打印</el-button>
                      </td>
                      <td>
                          <el-button @click="btnExport">导出</el-button>
                      </td>
                      <td>
                          <el-button @click="btnBatchSend">批次发布</el-button>
                      </td>
                      <td>
                          <el-button @click="btnBatchBack">批次召回</el-button>
                      </td>
                      <td>
                          <el-button @click="btnPublicSign">公共证书签名</el-button>
                      </td>
                      <td>
                          <el-button @click="btnElectronicSign">电子签名</el-button>
                      </td>
                      <!-- <td>
                          <el-button @click="btnUnSign">批次解签</el-button>
                      </td> -->
                  </tr>
              </table>
          </div>
      </div>
      <div class="pagecenter">
          <div class="middle-center">
              <div style="height: calc(100% - 55px); bottom: 40px">
                  <vxe-table :data.sync="LeftTableData" height="auto" highlight-current-row :loading="xTable1loading" highlight-hover-row highlight-hover-column resizable show-header-overflow="tooltip" border fit show-overflow="tooltip" header-align="center" size="mini" stripe ref="xTable1" @current-change="currentChangeEvent" :start-index="(tablePage.currentPage - 1) * tablePage.pageSize">
                      <vxe-table-column type="selection" width="45" align="center"></vxe-table-column>
                      <vxe-table-column field="sampledate" title="标本日期" width="90" sortable></vxe-table-column>
                      <vxe-table-column field="sampleno" title="标本编号" width="70" align="center">
                      </vxe-table-column>
                      <vxe-table-column field="barcode" title="条码号" width="80" align="center">
                      </vxe-table-column>
                      <vxe-table-column field="pat_name" title="姓名" width="60" sortable></vxe-table-column>
                      <vxe-table-column field="pat_no" title="病人号" width="100" align="center"></vxe-table-column>
                      <vxe-table-column field="pat_sex" title="性别" width="50" align="center"></vxe-table-column>
                      <vxe-table-column field="pat_agestr" title="年龄" width="50"></vxe-table-column>
                      <vxe-table-column field="specimen_name" title="标本类型" width="70">
                      </vxe-table-column>
                      <vxe-table-column field="cp_msg" title="发布消息提示" width="150" align="center">
                          <template v-slot="{ row }">
                              <div :style="ResultClass1(row)">
                                  <span>{{row.cp_msg}}</span>
                              </div>
                          </template>
                      </vxe-table-column>
                      <vxe-table-column field="release_user" title="发布人" width="70" align="center">
                      </vxe-table-column>
                      <vxe-table-column field="release_dt" title="发布时间" width="130" align="center">
                      </vxe-table-column>
                      <vxe-table-column field="rechk_username" title="审核医生" width="70" align="center"></vxe-table-column>
                      <vxe-table-column field="rechk_dt" title="审核时间" width="130" align="center"></vxe-table-column>
                      <vxe-table-column field="report_user" title="检验医生" width="70" align="center"></vxe-table-column>
                      <vxe-table-column field="report_dt" title="报告时间" width="130" align="center"></vxe-table-column>
                      <vxe-table-column field="rptunitid" title="报告单元" width="190"></vxe-table-column>
                  </vxe-table>
              </div>
              <div style="height: 52px">
                  <vxe-pager :loading="xTable1loading" :current-page="tablePage.currentPage" :page-size="tablePage.pageSize" :page-sizes="[20, 50, 100, 200, 500, 1000, 2000, 5000]" :total="tablePage.total" :layouts="['PrevPage', 'JumpNumber', 'NextPage', 'FullJump', 'Sizes', 'Total']" @page-change="handlePageChange"></vxe-pager>
              </div>
          </div>
          <div class="middle-right">
              <vxe-table :data.sync="RightTableData" height="auto" highlight-current-row :loading="xTable2loading" highlight-hover-row highlight-hover-column resizable show-header-overflow="tooltip" border fit show-overflow="tooltip" header-align="center" size="mini" stripe ref="xTable2">
                  <vxe-table-column field="rpt_itemname" title="检验项目" width="120" align="center">
                  </vxe-table-column>
                  <vxe-table-column field="result_str" title="检验结果" width="75" sortable align="right">
                      <template v-slot="{ row }">
                          <div :style="ResultClass(row)">
                              <span>{{row.result_str}}</span>
                          </div>
                      </template>
                  </vxe-table-column>
                  <vxe-table-column field="result_ref" title="参考值" width="70" align="center"></vxe-table-column>
                  <vxe-table-column field="result_unit" title="单位" width="60" sortable></vxe-table-column>
                  <vxe-table-column field="result_flag" title="结果状态" width="75" align="center"></vxe-table-column>
              </vxe-table>
          </div>
      </div>
      <!--多选弹窗--->
      <el-dialog width="900px" v-el-drag-dialog :append-to-body="true" :close-on-click-modal="false" title="申请科室" :visible.sync="dialogMultipleVisible" :destroy-on-close="true">
          <rm-SqlMultiple :leftOption="option1" :rightOption="option2" :name="fieldname" @change="closedialog"></rm-SqlMultiple>
      </el-dialog>
  </div>
</template>

<script type="text/javascript">
import XEUtils from "xe-utils";
export default {
  name: "LIS333",
  data() {
      return {
          tablePage: {
              currentPage: 1,
              pageSize: 100,
              total: 0,
          },
          emerOptions: [{ label: "", value: "" }, { label: "常规", value: "0" }, { label: "急诊", value: "1" }],
          chkOptions: [{ label: "全部", value: "" }, { label: "未发布", value: "0" }, { label: "已发布", value: "1" }],
          Options: {},
          deptOption: [],
          rptunitOption: [],
          option1: [],
          option2: [],
          fieldname: "",
          //查询条件
          txtrptunit: "",
          txtsampleno: "",
          txthospcode: "",
          txtdeptno: "",
          txtwardno: "",
          txtbedno: "",
          txtemer: "",
          rpt_startdt: "",
          rpt_enddt: this.$pub.InitDate(),
          txtbarcode: "",
          txtpattypecode: "",
          txtpatname: "",
          txtpatno: "",
          txtchkuserno: "",
          txtrptuserno:"",
          txtmixrpt: "0",//混样报告
          txtchkstate: "0",
          //选项
          chkpositiveRpt: "0",
          chkNoSignRpt: "0",
          chkForceSendOrBack: "0",
          chkSendOutHosp: "0",
          //表格
          xTable1loading: false,
          xTable2loading: false,
          RightTableData: [],
          LeftTableData: [],
          dialogMultipleVisible: false,
          sortArr: [],
          tableColumn: [],
          //用户信息
          usercode: "", //用户代码
          username: "", //用户姓名
          dataindex: 0, //数据index
          datasuccess: 0, //签名成功数量
          datafail: 0, //签名失败数量
          DealData: [], //待处理数据
          rechkcoverechkuser: "0"
      };
  },
  created() {
      this.InitDate();
      this.initOption(); //初始化下拉框的数据
      this.InitPage(); //初始化查询
  },
  mounted() {},
  updated() {},
  methods: {
      handlePageChange({ currentPage, pageSize }) {
          this.tablePage.currentPage = currentPage;
          this.tablePage.pageSize = pageSize;
          this.InitPage();
      },
      hospitalchange(code, name) {
          this.txthospcode = code;
      },
      userinfochange(code, name) {
          this.txtchkuserno = code;
      },
      rptuserinfochange(code,name){
          this.txtrptuserno=code;
      },
      popMultipleChk(e, fieldname, option, title) {
          let temp = XEUtils.clone(option, true);
          this.option1 = [];
          this.option2 = [];
          if (e != "") {
              let k = e.split(",");
              k.forEach(item => {
                  let ndata = temp.find(m => m.data == item);
                  if (ndata != undefined && ndata != null) {
                      this.option2.push(ndata);
                  }
              });
              temp.forEach(item => {
                  if (k.indexOf(item.data + "") < 0) {
                      this.option1.push(item);
                  }
              });
          } else {
              this.option1 = temp;
          }
          this.fieldname = fieldname;
          this.dialogMultipleVisible = true;
      },
      closedialog(value, name) {
          this[name] = value;
          this.dialogMultipleVisible = false;
      },
      InitDate() {
          //初始化时间
          var curDate = new Date();
          this.rpt_startdt = XEUtils.toDateString(new Date(curDate.getTime() - 24 * 60 * 60 * 1000), "yyyy-MM-dd"); //前一天
      },
      async initOption() {
          //后台查询
          try {
              const res = await this.$tool.request({
                  url: "LIS/LIS3/LIS333",
                  method: "post",
                  data: {
                      action: "initOption"
                  }
              });
              this.deptOption = res.deptOption;
              this.rptunitOption = res.rptunitOption;
              this.Options = res;
          } catch (e) {
              this.$message.warning(e);
          }
      },
      InitPage() {
          this.xTable1loading = true;
          this.$tool
              .request({
                  url: "LIS/LIS3/LIS333",
                  method: "post",
                  data: {
                      action: "InitPage",
                      txtrptunit: this.txtrptunit,
                      txtbarcode: this.txtbarcode,
                      txtsampleno: this.txtsampleno,
                      txtpatname: this.txtpatname,
                      txtdeptno: this.txtdeptno,
                      txtbedno: this.txtbedno,
                      txtpattypecode: this.txtpattypecode,
                      txtwardno: this.txtwardno,
                      txtpatno: this.txtpatno,
                      txtemer: this.txtemer,
                      txtchkstate: this.txtchkstate,
                      txtstarttime: this.rpt_startdt,
                      txtendtime: this.rpt_enddt,
                      txthospcode: this.txthospcode,
                      txtchkuserno: this.txtchkuserno,
                      txtrptuserno: this.txtrptuserno,
                      txtmixrpt: this.txtmixrpt,
                      chkpositiveRpt: this.chkpositiveRpt,
                      chkNoSignRpt: this.chkpositiveRpt,
                      chkForceSendOrBack: this.chkpositiveRpt,
                      chkSendOutHosp: this.chkpositiveRpt,
                      sortArr: this.sortArr,
                      pagesize: this.tablePage.pageSize,
                      currentpage: this.tablePage.currentPage,
                  }
              })
              .then(response => {
                  this.LeftTableData = response.Data;
                  this.tablePage.total = response.total;
                  this.loadFirstRow(this.$refs.xTable1, this.QueryDetail);
                  this.xTable1loading = false;
              })
              .catch(e => {
                  this.xTable1loading = false;
                  this.$message.warning(e);
              });
      },
      currentChangeEvent({ row }) {
          this.QueryDetail(row.reportid);
      },
      //自动加载表格的第一行，并执行回调函数
      loadFirstRow(xTable, func) {
          this.$nextTick(() => {
              // 加载第一行
              var selectrow = xTable.getData(0);
              if (selectrow) {
                  xTable.setCurrentRow(selectrow); //高亮行
                  xTable.scrollToRow(selectrow); //滚动到行
                  // this.currentChangeEventFun(selectrow);
                  if (typeof func == "function") func(selectrow.reportid);
              } else {
                  xTable.setCurrentRow(null); //这个不会自动清空
                  if (typeof func == "function") func("");
              }
          });
      },
      async QueryDetail(reportid) {
          this.xTable2loading = true;
          try {
              const res = await this.$tool.request({
                  url: "LIS/LIS3/LIS333",
                  method: "post",
                  data: {
                      action: "QueryDetail",
                      reportid: reportid
                  }
              });
              this.RightTableData = res.Data;
              this.loadFirstRow(this.$refs.xTable2, "");
              this.xTable2loading = false;
          } catch (e) {
              this.xTable2loading = false;
              this.$message.warning(e);
          }
      },
      btnQuery() {
          this.tablePage.currentPage = 1;
          this.InitPage();
      },
      btnSort() {
          if (this.tableColumn.length == 0) {
              let columns = this.$refs.xTable1.getColumns();
              columns.forEach(item => {
                  this.tableColumn.push({ title: item.title, field: item.property });
              });
          }
          this.$rmsort(
              { tableColumn: this.tableColumn, sortArr: this.sortArr },
              {
                  confirmButtonText: "确定",
                  cancelButtonText: "取消",
                  type: "warning"
              }
          )
              .then(res => {
                  this.sortArr = res.data;
                  this.InitPage();
              })
              .catch(() => {});
      },
      btnClear() {
          this.InitDate();
          this.rpt_enddt = this.$pub.InitDate();
          this.txtrptunit = "";
          this.txtsampleno = "";
          this.txthospcode = " ";
          this.txtdeptno = "";
          this.txtwardno = " ";
          this.txtbedno = "";
          this.txtemer = "";
          this.txtbarcode = "";
          this.txtpattypecode = " ";
          this.txtpatname = "";
          this.txtpatno = "";
          this.txtchkuserno = " ";
          this.txtrptuserno=" ";
          this.txtchkstate = "";
      },
      btnPrint() {},
      btnExport() {},
      btnBatchSend() {
          this.$rm_Login({
              type: "用户登录验证",
              btn: {
                  confirmBtnText: "确定",
                  cancelBtnText: "取消"
              }
          })
              .then(res => {
                  if (res.flag == "1") {
                      //登录成功
                      //let data = this.$refs.xTable1.getTableData().fullData;
                      let data = this.$refs.xTable1.getSelectRecords();
                      for (const item of data) {
                          this.BatchSendBefore(item, res.userid);
                          // console.info("ret.flag=="+ret.flag+"===ret.msg+==="+ret.msg);
                          // item.cp_msg = ret.msg;
                          // item.cp_flag = ret.flag;
                      }
                  }
              })
              .catch(e => {});
      },
      BatchSendBefore(item, reportuser) {
          console.info("1111111111111111111111")
          try {
              this.$tool
                  .request({
                      url: "LIS/LIS3/LIS333",
                      method: "post",
                      data: {
                          action: "btnBatchSend",
                          reportid: item.reportid,
                          reportuser: reportuser
                      }
                  })
                  .then(res => {
                      item.cp_msg = res.msg;
                      item.cp_flag = res.flag;
                  });
          } catch (e) {
              this.$message.warning(e);
          }
      },
      async btnBatchBack() {
          this.$rm_Login({
              type: "用户登录验证",
              btn: {
                  confirmBtnText: "确定",
                  cancelBtnText: "取消"
              }
          })
              .then(async res => {
                  if (res.flag == "1") {
                      //登录成功
                      //let data = this.$refs.xTable1.getTableData().fullData;
                      let data = this.$refs.xTable1.getSelectRecords();
                      for (const item of data) {
                          var ret = await this.BatchBackBefore(item.reportid, res.userid);
                           console.info("ret.flag=="+ret.flag+"===ret.msg+==="+ret.msg);
                          item.cp_msg = ret.msg;
                          item.cp_flag = ret.flag;
                      }
                  }
              })
              .catch(e => {});
      },
      async BatchBackBefore(reportid, reportuser) {
          try {
              const res = await this.$tool.request({
                  url: "LIS/LIS3/LIS333",
                  method: "post",
                  data: {
                      action: "btnBatchBack",
                      reportid: reportid,
                      reportuser: reportuser
                  }
              });
              return res;
          } catch (e) {
              this.$message.warning(e);
          }
      },
      ResultClass(row) {
          var stylestr = "padding:0 3px;";
          if (this.Options.resultcolor_mode == "1") stylestr += "color:";
          else stylestr += "background-color:";
          switch (row.result_flag) {
              case "M":
                  stylestr += this.Options.resultcolor_m;
                  break;
              case "H":
                  stylestr += this.Options.resultcolor_h;
                  break;
              case "L":
                  stylestr += this.Options.resultcolor_l;
                  break;
              case "P":
                  stylestr += this.Options.resultcolor_p;
                  break;
              case "W":
                  stylestr += this.Options.resultcolor_w;
                  break;
              case "E":
                  stylestr += this.Options.resultcolor_e;
                  break;
              case "Q":
                  stylestr += this.Options.resultcolor_r;
                  break;
              default:
                  stylestr += this.Options.resultcolor_m;
                  break;
          }
          if (row.result_str == "未做") {
              stylestr += ";color: #0095D9";
          }
          return stylestr;
      },
      ResultClass1(row){
          var stylestr = "";
         console.info("row.cp_flag=="+row.cp_flag) ;
          if(row.cp_flag <= -1){
              stylestr = "padding:0 3px;background-color:#FFC0CB";
          }
          return stylestr;
      },
      btnPublicSign() {},
      btnElectronicSign() {
          if (this.usercode) {
              this.DealData = this.$refs.xTable1.getSelectRecords();
              this.dataindex = 0;
              this.datasuccess = 0;
              this.datafail = 0;
              if (this.DealData.length > 0) {
                  this.SignReport(this.DealData[this.dataindex]);
              }
          } else {
              this.$rm_Login({
                  type: "用户登录验证",
                  btn: {
                      confirmBtnText: "确定",
                      cancelBtnText: "取消"
                  }
              })
                  .then(res => {
                      if (res.flag == "1") {
                          //登录成功
                          this.usercode = res.userid;
                          this.username = res.username;
                          this.DealData = this.$refs.xTable1.getSelectRecords();
                          this.dataindex = 0;
                          this.datasuccess = 0;
                          this.datafail = 0;
                          if (this.DealData.length > 0) {
                              this.SignReport(this.DealData[this.dataindex]);
                          } else {
                              this.$alert("未选中要签名的数据", "提示");
                          }
                      }
                  })
                  .catch(e => {});
          }
      },
      SignReport(row) {
          let rckuser = !row.rechk_user ? this.usercode : row.rechk_user;
          let rckusername = !row.rechk_username ? this.username : row.rechk_username;
          this.$tool
              .request({
                  url: "LIS/LIS3/LIS333",
                  method: "post",
                  data: {
                      action: "SignReport",
                      reportid: row.reportid,
                      checkuser: rckuser
                  }
              })
              .then(res => {
                  this.$ca.CAsign(rckuser, res.reporttoca.data, res.reporttoca.reportid).then(caret => {
                      //this.$pub.Log("电子签名结束");
                      if (caret.flag != "1") {
                          this.$pub.Log("CA签名失败：chkuser=" + rckusername + "reportid = " + res.reporttoca.reportid + ",data=" + res.reporttoca.data);
                          this.DealData[this.dataindex].cp_msg = "电子签名失败";
                          this.dataindex++;
                          this.datafail++;
                          if (this.dataindex < this.DealData.length) this.SignReport(this.DealData[this.dataindex]);
                          else {
                              this.AlertMsg(1);
                          }
                      } else {
                          this.DealData[this.dataindex].cp_msg = "电子签名成功";
                          this.dataindex++;
                          this.datasuccess++;
                          if (this.dataindex < this.DealData.length) this.SignReport(this.DealData[this.dataindex]);
                          else {
                              this.AlertMsg(1);
                          }
                      }
                  });
              });
      },
      btnUnSign() {
          if (this.usercode) {
              this.DealData = this.$refs.xTable1.getSelectRecords();
              this.dataindex = 0;
              this.datasuccess = 0;
              this.datafail = 0;
              if (this.DealData.length > 0) {
                  this.UnSignReport(this.DealData[this.dataindex]);
              }
          } else {
              this.$rm_Login({
                  type: "用户登录验证",
                  btn: {
                      confirmBtnText: "确定",
                      cancelBtnText: "取消"
                  }
              })
                  .then(res => {
                      if (res.flag == "1") {
                          //登录成功
                          this.usercode = res.userid;
                          this.username = res.username;
                          this.DealData = this.$refs.xTable1.getSelectRecords();
                          this.dataindex = 0;
                          this.datasuccess = 0;
                          this.datafail = 0;
                          if (this.DealData.length > 0) {
                              this.UnSignReport(this.DealData[this.dataindex]);
                          } else {
                              this.$alert("未选中要签名的数据", "提示");
                          }
                      }
                  })
                  .catch(e => {});
          }
      },
      //解除签名
      UnSignReport(row) {
          let rckuser = !row.rechk_user ? this.usercode : row.rechk_user;
          this.$tool
              .request({
                  url: "LIS/LIS3/LIS333",
                  method: "post",
                  data: {
                      action: "unsignreport",
                      reportid: row.reportid,
                      checkuser: rckuser
                  }
              })
              .then(res => {
                  if (res.flag != "1") {
                      this.DealData[this.dataindex].cp_msg = "解除电子签名失败";
                      this.dataindex++;
                      this.datafail++;
                      if (this.dataindex < this.DealData.length) this.UnSignReport(this.DealData[this.dataindex]);
                      else {
                          this.AlertMsg(2);
                      }
                  } else {
                      this.DealData[this.dataindex].cp_msg = "解除电子签名成功";
                      this.dataindex++;
                      this.datasuccess++;
                      if (this.dataindex < this.DealData.length) this.UnSignReport(this.DealData[this.dataindex]);
                      else {
                          this.AlertMsg(2);
                      }
                  }
              });
      },
      AlertMsg(type) {
          if (type == 2) this.$alert("选中报告全部解除签名完毕!" + this.datasuccess + "条解除签名成功," + this.datafail + "条解除签名失败", "提示");
          else this.$alert("选中报告全部签名完毕!" + this.datasuccess + "条签名成功," + this.datafail + "条签名失败", "提示");
      }
  }
};
</script>

<style scoped>
.pagetop {
  width: 100%;
  height: 145px;
  -webkit-box-pack: left;
  -webkit-box-align: center;
  border: 1px solid #ccc;
  position: absolute;
  z-index: 99;
}

.pagecenter {
  position: absolute;
  top: 150px;
  width: 100%;
  left: 0;
  bottom: 0px;
  overflow: auto;
}

.middle-center {
  position: absolute;
  height: 100%;
  left: 0px;
  right: 405px;
  overflow: auto;
}

.middle-right {
  position: absolute;
  height: 100%;
  width: 400px;
  right: 0px;
}
</style>